package com.lingyun.web.controller;

import com.lingyun.model.db.SatelliteRsData;
import com.lingyun.service.SatelliteRsDataService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by bai on 2017/7/24.
 */
@Controller
@RequestMapping("")
public class IndexController {

    private static final Log logger = LogFactory.getLog(IndexController.class);

    @Autowired
    private SatelliteRsDataService satelliteRsDataService;

    @RequestMapping({"", "/", "/index.html"})
    public String index() {
        return "index";
    }

    @RequestMapping("search-by-data.ajax")
    @ResponseBody
    public List<SatelliteRsData> search(String startDate, String endDate, float minLat, float maxLat, float minLng, float maxLng) {
        logger.debug("开始查询");

        List<SatelliteRsData> list = satelliteRsDataService.findByParams(startDate,endDate,minLat,maxLat,minLng,maxLng);
        logger.debug("查询结果：");
        logger.debug(list);
        return list;
    }
}
